<?php
namespace app\controllers;
use Yii;
use yii\web\Controller;
use app\models\Goods;
use yii\data\Pagination;
 class BitchController extends Controller
 {
  	public function actionIndex() 
  	{
      return $this->render('index');
  	}
	public function actionIndex_do()
  	{
      $data=yii::$app->request->post();
      $model=new Goods();
      $goods=$model->add($data);
      if($goods){
        $this->redirect(['show']);
       }else{  
       	$this->redirect(['index']);
       }
   	}
  	
  	public function actionShow()
  	{
	  	$query = Goods::find();
	    $countQuery = clone $query;
	    $pages = new Pagination(['totalCount' => $countQuery->count(),'defaultPageSize' => 5]);
	    $models = $query->offset($pages->offset)
	        ->limit($pages->limit)
	        ->all();
	    return $this->render('shop', [
	         'models' => $models,
	         'pages' => $pages,
	    ]);
	  	} 
     

    }



?>